package algorithm;


import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;

/**
 * create by yongli on 2021-04-14 00:14
 */

public class Lc49 {
    public static void main(String[] args) {
        System.out.println(" ".charAt(0));
        // 32
        System.out.println((int)" ".charAt(0));
    }
    public List<List<String>> groupAnagrams(String[] strs) {



        Map<String, List<String>> map = new HashMap<String, List<String>>();
        for (String str : strs) {
            // 也不用for，直接to
            char[] array = str.toCharArray();
            char[] arr2 = new char[str.length()];
                  arr2=  Arrays.copyOf(array,array.length);
            Arrays.sort(array);
            String key = new String(array);
            // 好家伙，没有就使用默认值，不用判断了, 放到一个桶里面
            List<String> list = map.getOrDefault(key, new ArrayList<String>());
            list.add(str);
            map.put(key, list);
        }
        return new ArrayList<List<String>>(map.values());
    }
}